package com.ccloud.blog.modules.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccloud.blog.modules.blog.domain.BlogTag;
import com.ccloud.blog.modules.blog.mapper.BlogTagMapper;
import com.ccloud.blog.modules.blog.service.IBlogTagService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author chentailai
 * @since 2019-09-10
 */
@Service
public class BlogTagServiceImpl extends ServiceImpl<BlogTagMapper, BlogTag> implements IBlogTagService {
    @Override
    public List<Map<String, Object>> getBloyTagList() {
        QueryWrapper<BlogTag> wrapper = new QueryWrapper<>();
        wrapper.orderByAsc("id");
        List<Map<String, Object>> list = this.listMaps(wrapper);
        return list;
    }

    @Override
    public boolean insertBlogTagByName(String blogTagName) {
//        LoginUser loginUser = RequestHolder.getCurrentUser();
//        Integer loginId = loginUser.getId();
        Integer loginId = 1;
        BlogTag blogTag = new BlogTag();
        blogTag.setName(blogTagName);
        blogTag.setCreateBy(loginId);
        blogTag.setUpdateBy(loginId);
        return save(blogTag);
    }
}
